package com.sjtu.vfact.textual.view;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener;
import javax.swing.event.TableModelListener;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;

import com.sjtu.vfact.textual.tablemodel.DetailSummarizerTableModel;
import com.sjtu.vfact.textual.tablemodel.MasterCollectionTableModel;
import com.sjtu.vfact.textual.tablemodel.QuickSummarizerTableModel;
import com.sjtu.vfact.textual.tablemodel.UncoveredTermsTableModel;
import com.sjtu.vfact.textual.tablemodel.VFactTableModel;
import com.sjtu.vfact.textual.util.RowNumberTable;

public class FACTAFrame extends JFrame {

	private static final long serialVersionUID = 6013630972457261012L;
	
	private JPanel contentPane;
	
	private JTable tableMasterCollection;
	private JTable tableUncoveredTerms;
	private JTable tableQuickSum;
	private JTable tableDetailSum;
//	private TableRowSorter<TableModel> masterCollectionSorter;
//	private TableRowSorter<TableModel> uncoveredTermsSorter;
//	private TableRowSorter<TableModel> quickSumSorter;
//	private TableRowSorter<TableModel> detailSumSorter;
	
	private JLabel lblStatusUpdate;
	
	private JTextField txtFldFileName;
	private JTextField txtFldLengthMin;
	private JTextField txtFldLengthMax;
	private JTextField txtFldNumberN;
	private JTextField txtFldP;
	private JTextArea txtAreaCollecting;
	
	private JButton btnFactaA;
	private JButton btnFactaB;
	private JButton btnFactaC;
	private JButton btnFactaD;
	private JButton btnOpenFile;
	private JButton btnShowGraph;
	
	private JProgressBar prgBarCollecting;
	private JProgressBar prgBarCoverage;
	private JProgressBar prgBarSpecificity;
	private JProgressBar prgBarDensity;
	
	private JSpinner spinnerCSD;
	
	private JButton btnQuickSum;
	private JButton btnDetailSum;
	
	private JTextField txtFldSSARange;
	private JComboBox cmbBoxSSARanges;
	private JButton btnShowSSAGraph;
	private JTextArea txtAreaSSA;
	private JButton btnRunSSA;

	/**
	 * Create the frame.
	 */
	public FACTAFrame() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1034, 743);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JPanel panelTop = new JPanel();
		panelTop.setBorder(new TitledBorder(null, "Table Master Collection", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelTop.setBounds(6, 6, 1012, 283);
		panel.add(panelTop);
		
		JScrollPane scrollPaneMasterTermset = new JScrollPane();
		scrollPaneMasterTermset.setPreferredSize(new Dimension(1000, 250));
		panelTop.add(scrollPaneMasterTermset);
		
		tableMasterCollection = new JTable(){

			private static final long serialVersionUID = 1L;

			@Override
			protected JTableHeader createDefaultTableHeader() {
				return new JTableHeader(columnModel){
					private static final long serialVersionUID = 1L;

					public String getToolTipText(MouseEvent e) {
						String tip = null;
						Point p = e.getPoint();
						int index = columnModel.getColumnIndexAtX(p.x);
						int realIndex = columnModel.getColumn(index).getModelIndex();
						switch (realIndex) {
						case MasterCollectionTableModel.COL_TERMSET:
							tip = "This is Termset";
							break;
						case MasterCollectionTableModel.COL_SUPPORT:
							tip = "This is Support";
							break;
						case MasterCollectionTableModel.COL_DOCPAIRS:
							tip = "This is Document Pairs";
							break;
						default:
							break;
						}
						return tip;
					}
				};
			}
		};
		scrollPaneMasterTermset.setViewportView(tableMasterCollection);
		JTable rowTableMasterCollection = new RowNumberTable(tableMasterCollection);
		scrollPaneMasterTermset.setRowHeaderView(rowTableMasterCollection);
		scrollPaneMasterTermset.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowTableMasterCollection.getTableHeader());
		tableMasterCollection.setAutoCreateRowSorter(true);
		tableMasterCollection.setFillsViewportHeight(true);
		
		JPanel panelBottom = new JPanel();
		panelBottom.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panelBottom.setBounds(6, 301, 1012, 404);
		panel.add(panelBottom);
		
		JTabbedPane tabbedPane = new JTabbedPane();
		tabbedPane.setPreferredSize(new Dimension(1000, 400));
		panelBottom.add(tabbedPane);
		
		JPanel panelMiningTask = new JPanel();
		tabbedPane.addTab("Mining Task", null, panelMiningTask, null);
		panelMiningTask.setLayout(null);
		
		JPanel panelMasterCollectionGeneration = new JPanel();
		panelMasterCollectionGeneration.setBorder(new TitledBorder(null, "Master Collection Generation", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelMasterCollectionGeneration.setBounds(6, 6, 478, 342);
		panelMiningTask.add(panelMasterCollectionGeneration);
		panelMasterCollectionGeneration.setLayout(null);
		
		JLabel lblFileName = new JLabel("File Name :");
		lblFileName.setBounds(16, 31, 90, 16);
		panelMasterCollectionGeneration.add(lblFileName);
		
		txtFldFileName = new JTextField();
		txtFldFileName.setEditable(false);
		txtFldFileName.setBounds(101, 25, 325, 28);
		panelMasterCollectionGeneration.add(txtFldFileName);
		txtFldFileName.setColumns(10);
		
		btnOpenFile = new JButton("...");
		btnOpenFile.setBounds(432, 26, 40, 29);
		panelMasterCollectionGeneration.add(btnOpenFile);
		
		JLabel lblStatus = new JLabel("Status :");
		lblStatus.setBounds(16, 59, 90, 16);
		panelMasterCollectionGeneration.add(lblStatus);
		
		lblStatusUpdate = new JLabel("");
		lblStatusUpdate.setBounds(101, 59, 325, 16);
		panelMasterCollectionGeneration.add(lblStatusUpdate);
		
		JLabel lblLength = new JLabel("Length (L) min - max :");
		lblLength.setBounds(16, 87, 153, 16);
		panelMasterCollectionGeneration.add(lblLength);
		
		txtFldLengthMin = new JTextField();
		txtFldLengthMin.setText("1");
		txtFldLengthMin.setBounds(171, 81, 68, 28);
		panelMasterCollectionGeneration.add(txtFldLengthMin);
		txtFldLengthMin.setColumns(10);
		
		txtFldLengthMax = new JTextField();
		txtFldLengthMax.setText("100");
		txtFldLengthMax.setColumns(10);
		txtFldLengthMax.setBounds(297, 81, 68, 28);
		panelMasterCollectionGeneration.add(txtFldLengthMax);
		
		JLabel lblMinMax = new JLabel("-");
		lblMinMax.setAlignmentX(Component.CENTER_ALIGNMENT);
		lblMinMax.setBounds(266, 87, 19, 16);
		panelMasterCollectionGeneration.add(lblMinMax);
		
		JLabel lblNumber = new JLabel("Number (N) :");
		lblNumber.setBounds(16, 121, 90, 16);
		panelMasterCollectionGeneration.add(lblNumber);
		
		txtFldNumberN = new JTextField();
		txtFldNumberN.setText("100");
		txtFldNumberN.setColumns(10);
		txtFldNumberN.setBounds(115, 115, 68, 28);
		panelMasterCollectionGeneration.add(txtFldNumberN);
		
		JLabel lblP = new JLabel("P :");
		lblP.setBounds(254, 121, 40, 16);
		panelMasterCollectionGeneration.add(lblP);
		
		txtFldP = new JTextField();
		txtFldP.setText("5");
		txtFldP.setColumns(10);
		txtFldP.setBounds(297, 115, 68, 28);
		panelMasterCollectionGeneration.add(txtFldP);
		
		JPanel panelButtonFacta = new JPanel();
		panelButtonFacta.setBorder(new TitledBorder(null, "FACTA", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelButtonFacta.setBounds(16, 160, 205, 133);
		panelMasterCollectionGeneration.add(panelButtonFacta);
		panelButtonFacta.setLayout(null);
		
		btnFactaA = new JButton("FACTA-A");
		btnFactaA.setBounds(6, 36, 92, 29);
		panelButtonFacta.add(btnFactaA);
		
		btnFactaC = new JButton("FACTA-C");
		btnFactaC.setBounds(103, 36, 96, 29);
		panelButtonFacta.add(btnFactaC);
		
		btnFactaB = new JButton("FACTA-B");
		btnFactaB.setBounds(6, 77, 92, 29);
		panelButtonFacta.add(btnFactaB);
		
		btnFactaD = new JButton("FACTA-D");
		btnFactaD.setBounds(107, 77, 92, 29);
		panelButtonFacta.add(btnFactaD);
		
		JPanel panelButtonShowGraph = new JPanel();
		panelButtonShowGraph.setBounds(16, 297, 444, 39);
		panelMasterCollectionGeneration.add(panelButtonShowGraph);
		
		btnShowGraph = new JButton("Show Graph");
		panelButtonShowGraph.add(btnShowGraph);
		
		JPanel panelProgress = new JPanel();
		panelProgress.setBorder(new TitledBorder(null, "Progress", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelProgress.setBounds(233, 160, 227, 133);
		panelMasterCollectionGeneration.add(panelProgress);
		panelProgress.setLayout(null);
		
		prgBarCollecting = new JProgressBar(0, 100);
		prgBarCollecting.setValue(0);
		prgBarCollecting.setStringPainted(true);
		prgBarCollecting.setBounds(16, 21, 193, 20);
		panelProgress.add(prgBarCollecting);
		
		JScrollPane scrollPaneTxtAreaCollecting = new JScrollPane();
		scrollPaneTxtAreaCollecting.setBounds(16, 49, 193, 78);
		panelProgress.add(scrollPaneTxtAreaCollecting);
		
		txtAreaCollecting = new JTextArea();
		txtAreaCollecting.setMargin(new Insets(2, 2, 2, 2));
		txtAreaCollecting.setEditable(false);
		scrollPaneTxtAreaCollecting.setViewportView(txtAreaCollecting);
		
		JPanel panelQualityInspection = new JPanel();
		panelQualityInspection.setBorder(new TitledBorder(null, "Quality Inspection", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelQualityInspection.setBounds(495, 6, 478, 342);
		panelMiningTask.add(panelQualityInspection);
		panelQualityInspection.setLayout(null);
		
		JPanel panelCSD = new JPanel();
		panelCSD.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panelCSD.setBounds(16, 25, 445, 100);
		panelQualityInspection.add(panelCSD);
		panelCSD.setLayout(null);
		
		JLabel lblCsdInSupport = new JLabel("CSD in Support :");
		lblCsdInSupport.setBounds(18, 22, 155, 16);
		panelCSD.add(lblCsdInSupport);
		
		spinnerCSD = new JSpinner(new SpinnerNumberModel(2, 2, 20, 1));
		spinnerCSD.setBounds(18, 50, 107, 28);
		spinnerCSD.setEnabled(false);
		panelCSD.add(spinnerCSD);
		
		prgBarCoverage = new JProgressBar(0, 100);
		prgBarCoverage.setBounds(171, 18, 146, 20);
		panelCSD.add(prgBarCoverage);
		
		prgBarDensity = new JProgressBar(0, 100);
		prgBarDensity.setBounds(171, 66, 146, 20);
		panelCSD.add(prgBarDensity);
		
		prgBarSpecificity = new JProgressBar(0, 100);
		prgBarSpecificity.setBounds(171, 42, 146, 20);
		panelCSD.add(prgBarSpecificity);
		
		JLabel lblCoverage = new JLabel("Coverage");
		lblCoverage.setBounds(332, 18, 89, 16);
		panelCSD.add(lblCoverage);
		
		JLabel lblSpecificity = new JLabel("Specificity");
		lblSpecificity.setBounds(332, 42, 89, 16);
		panelCSD.add(lblSpecificity);
		
		JLabel lblDensity = new JLabel("Density");
		lblDensity.setBounds(332, 66, 89, 16);
		panelCSD.add(lblDensity);
		
		JPanel panelTableUncoveredTerms = new JPanel();
		panelTableUncoveredTerms.setBorder(new TitledBorder(null, "Table Uncovered Terms", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelTableUncoveredTerms.setBounds(16, 132, 445, 193);
		panelQualityInspection.add(panelTableUncoveredTerms);
		
		JScrollPane scrollPaneUncoveredTerms = new JScrollPane();
		scrollPaneUncoveredTerms.setPreferredSize(new Dimension(430, 160));
		panelTableUncoveredTerms.add(scrollPaneUncoveredTerms);
		
		tableUncoveredTerms = new JTable(){
			private static final long serialVersionUID = 1L;

			@Override
			protected JTableHeader createDefaultTableHeader() {
				return new JTableHeader(columnModel){
					private static final long serialVersionUID = 1L;

					public String getToolTipText(MouseEvent e) {
						String tip = null;
						Point p = e.getPoint();
						int index = columnModel.getColumnIndexAtX(p.x);
						int realIndex = columnModel.getColumn(index).getModelIndex();
						switch (realIndex) {
						case UncoveredTermsTableModel.COL_UNCOVERED_TERMS:
							tip = "This is Uncovered Terms";
							break;
						case UncoveredTermsTableModel.COL_DOCIDS:
							tip = "This is DocIDs";
							break;
						case UncoveredTermsTableModel.COL_SUPPORT:
							tip = "This is Support";
							break;
						default:
							break;
						}
						return tip;
					}
				};
			}
		};
		scrollPaneUncoveredTerms.setViewportView(tableUncoveredTerms);
		JTable rowTableUncoveredTerms = new RowNumberTable(tableUncoveredTerms);
		scrollPaneUncoveredTerms.setRowHeaderView(rowTableUncoveredTerms);
		scrollPaneUncoveredTerms.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowTableUncoveredTerms.getTableHeader());
		tableUncoveredTerms.setFillsViewportHeight(true);
		
		JPanel panelSummarizer = new JPanel();
		tabbedPane.addTab("Summarizer", null, panelSummarizer, null);
		panelSummarizer.setLayout(new GridLayout(0, 2, 10, 0));
		
		JPanel panelQuickSum = new JPanel();
		panelQuickSum.setBorder(new TitledBorder(null, "Quick Summarizer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelSummarizer.add(panelQuickSum);
		panelQuickSum.setLayout(new BorderLayout(0, 5));
		
		JPanel panelBtnQuickSum = new JPanel();
		panelQuickSum.add(panelBtnQuickSum, BorderLayout.SOUTH);
		
		btnQuickSum = new JButton("Quick Summarizer");
		panelBtnQuickSum.add(btnQuickSum);
		
		JPanel panelTableQuickSum = new JPanel();
		panelQuickSum.add(panelTableQuickSum, BorderLayout.CENTER);
		
		JScrollPane scrollPaneQuickSum = new JScrollPane();
		scrollPaneQuickSum.setPreferredSize(new Dimension(460, 273));
		panelTableQuickSum.add(scrollPaneQuickSum);
		
		tableQuickSum = new JTable(){
			private static final long serialVersionUID = 1L;

			@Override
			protected JTableHeader createDefaultTableHeader() {
				return new JTableHeader(columnModel){
					private static final long serialVersionUID = 1L;

					public String getToolTipText(MouseEvent e) {
						String tip = null;
						Point p = e.getPoint();
						int index = columnModel.getColumnIndexAtX(p.x);
						int realIndex = columnModel.getColumn(index).getModelIndex();
						switch (realIndex) {
						case QuickSummarizerTableModel.COL_SUMMARY:
							tip = "This is Quick Summary";
							break;
						case QuickSummarizerTableModel.COL_DOCIDS:
							tip = "This is DocIDs";
							break;
						case QuickSummarizerTableModel.COL_SUPPORT:
							tip = "This is Support";
							break;
						default:
							break;
						}
						return tip;
					}
				};
			}
		};
		scrollPaneQuickSum.setViewportView(tableQuickSum);
		JTable rowTableQuickSum = new RowNumberTable(tableQuickSum);
		scrollPaneQuickSum.setRowHeaderView(rowTableQuickSum);
		scrollPaneQuickSum.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowTableQuickSum.getTableHeader());
		tableQuickSum.setFillsViewportHeight(true);
		
		JPanel panelDetailSum = new JPanel();
		panelDetailSum.setBorder(new TitledBorder(null, "Detail Summarizer", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panelSummarizer.add(panelDetailSum);
		panelDetailSum.setLayout(new BorderLayout(0, 5));
		
		JPanel panelBtnDetailSum = new JPanel();
		panelDetailSum.add(panelBtnDetailSum, BorderLayout.SOUTH);
		
		btnDetailSum = new JButton("Detail Summarizer");
		panelBtnDetailSum.add(btnDetailSum);
		
		JPanel panelTableDetailSum = new JPanel();
		panelDetailSum.add(panelTableDetailSum, BorderLayout.CENTER);
		
		JScrollPane scrollPaneDetailSum = new JScrollPane();
		scrollPaneDetailSum.setPreferredSize(new Dimension(460, 273));
		panelTableDetailSum.add(scrollPaneDetailSum);
		
		tableDetailSum = new JTable(){
			private static final long serialVersionUID = 1L;

			@Override
			protected JTableHeader createDefaultTableHeader() {
				return new JTableHeader(columnModel){
					private static final long serialVersionUID = 1L;

					public String getToolTipText(MouseEvent e) {
						String tip = null;
						Point p = e.getPoint();
						int index = columnModel.getColumnIndexAtX(p.x);
						int realIndex = columnModel.getColumn(index).getModelIndex();
						switch (realIndex) {
						case DetailSummarizerTableModel.COL_SUMMARY:
							tip = "This is Detail Summary";
							break;
						case DetailSummarizerTableModel.COL_DOCIDS:
							tip = "This is DocIDs";
							break;
						case DetailSummarizerTableModel.COL_SUPPORT:
							tip = "This is Support";
							break;
						default:
							break;
						}
						return tip;
					}
				};
			}
		};
		scrollPaneDetailSum.setViewportView(tableDetailSum);
		JTable rowTableDetailSum = new RowNumberTable(tableDetailSum);
		scrollPaneDetailSum.setRowHeaderView(rowTableDetailSum);
		scrollPaneDetailSum.setCorner(JScrollPane.UPPER_LEFT_CORNER, rowTableDetailSum.getTableHeader());
		tableDetailSum.setFillsViewportHeight(true);
		
		JPanel panelSSA = new JPanel();
		tabbedPane.addTab("SSA", null, panelSSA, null);
		panelSSA.setLayout(new BorderLayout(0, 10));
		
		JPanel panelSSASetting = new JPanel();
		panelSSA.add(panelSSASetting, BorderLayout.NORTH);
		panelSSASetting.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		JLabel lblSSARange = new JLabel("SSA Range : ");
		panelSSASetting.add(lblSSARange);
		
		txtFldSSARange = new JTextField();
		panelSSASetting.add(txtFldSSARange);
		txtFldSSARange.setColumns(18);
		
		btnRunSSA = new JButton("Run");
		panelSSASetting.add(btnRunSSA);
		
		cmbBoxSSARanges = new JComboBox();
		cmbBoxSSARanges.setPreferredSize(new Dimension(130, 27));
		panelSSASetting.add(cmbBoxSSARanges);
		
		btnShowSSAGraph = new JButton("Show SSA Graph");
		panelSSASetting.add(btnShowSSAGraph);
		
		JPanel panelTxtAreaSSA = new JPanel();
		panelSSA.add(panelTxtAreaSSA, BorderLayout.CENTER);
		
		JScrollPane scrollPaneSSA = new JScrollPane();
		scrollPaneSSA.setPreferredSize(new Dimension(970, 295));
		panelTxtAreaSSA.add(scrollPaneSSA);
		
		txtAreaSSA = new JTextArea();
		scrollPaneSSA.setViewportView(txtAreaSSA);
	}
	
//	public JFrame getFrame(){
//		return this.frmFactMiner;
//	}
	
	public void displayFrame(){
		setVisible(true);
	}
	
	public void addBtnFactaAListener(ActionListener l){
		btnFactaA.addActionListener(l);
	}
	
	public void addBtnFactaBListener(ActionListener l){
		btnFactaB.addActionListener(l);
	}
	
	public void addBtnFactaCListener(ActionListener l){
		btnFactaC.addActionListener(l);
	}
	
	public void addBtnFactaDListener(ActionListener l){
		btnFactaD.addActionListener(l);
	}
	
	public void addBtnOpenFileListener(ActionListener l){
		btnOpenFile.addActionListener(l);
	}
	
	public void addBtnQuickSumListener(ActionListener l){
		btnQuickSum.addActionListener(l);
	}
	
	public void addBtnDetailSumListener(ActionListener l){
		btnDetailSum.addActionListener(l);
	}
	
	public void addBtnShowGraphListener(ActionListener l){
		btnShowGraph.addActionListener(l);
	}
	
	public void addBtnRunSSAListener(ActionListener l){
		btnRunSSA.addActionListener(l);
	}
	
	public void addBtnShowSSAGraphListener(ActionListener l){
		btnShowSSAGraph.addActionListener(l);
	}
	
	public void addSpinnerCSDListener(ChangeListener l){
		spinnerCSD.addChangeListener(l);
	}
	
	public void addTableMasterCollectionListener(TableModelListener l){
		tableMasterCollection.getModel().addTableModelListener(l);
	}
	
	public void addTableQuickSumListener(TableModelListener l){
		tableQuickSum.getModel().addTableModelListener(l);
	}
	
	public void addTableDetailSumListerner(TableModelListener l){
		tableDetailSum.getModel().addTableModelListener(l);
	}
	
	public void addTableUncoveredTermsListener(TableModelListener l){
		tableUncoveredTerms.getModel().addTableModelListener(l);
	}
	
	public void setTableMasterCollectionModelAndSorter(VFactTableModel tableModel){
		tableMasterCollection.setModel(tableModel);
//		masterCollectionSorter = new TableRowSorter<TableModel>(tableMasterCollection.getModel());
//		tableMasterCollection.setRowSorter(masterCollectionSorter);
	}
	
	public void setTableQuickSumModelAndSorter(VFactTableModel tableModel){
		tableQuickSum.setModel(tableModel);
//		quickSumSorter = new TableRowSorter<TableModel>(tableQuickSum.getModel());
//		tableQuickSum.setRowSorter(quickSumSorter);
	}
	
	public void setTableDetailSumModelAndSorter(VFactTableModel tableModel){
		tableDetailSum.setModel(tableModel);
//		detailSumSorter = new TableRowSorter<TableModel>(tableDetailSum.getModel());
//		tableDetailSum.setRowSorter(detailSumSorter);
	}
	
	public void setTableUncoveredTermsModelAndSorter(VFactTableModel tableModel){
		tableUncoveredTerms.setModel(tableModel);
//		uncoveredTermsSorter = new TableRowSorter<TableModel>(tableUncoveredTerms.getModel());
//		tableUncoveredTerms.setRowSorter(uncoveredTermsSorter);
	}

	public void setSpinnerCSDValue(int minValue, int maxValue){
		SpinnerNumberModel model = (SpinnerNumberModel) spinnerCSD.getModel();
		model.setMinimum(minValue);
		model.setMaximum(maxValue);
	}
	
	public void setEnabledSpinnerCSD(boolean state){
		spinnerCSD.setEnabled(state);
	}
	
	public String getTxtFldFileName(){
		return txtFldFileName.getText();
	}
	
	public void setTxtFldFileName(String text){
		txtFldFileName.setText(text);
	}
	
	public void setLblStatus(String text){
		lblStatusUpdate.setText(text);
	}
	
	public void appendTxtAreaCollecting(String text){
		txtAreaCollecting.append(text);
	}
	
	public void clearTxtAreaCollecting(){
		txtAreaCollecting.setText("");
	}
	
	public int getLengthMin(){
		return Integer.parseInt(txtFldLengthMin.getText());
	}
	
	public int getLengthMax(){
		return Integer.parseInt(txtFldLengthMax.getText());
	}
	
	public int getNumberN(){
		return Integer.parseInt(txtFldNumberN.getText());
	}
	
	public int getP(){
		return Integer.parseInt(txtFldP.getText());
	}
	
	public String getSSARanges(){
		return txtFldSSARange.getText();
	}
	
	public void setCollectingProgress(int progress){
		prgBarCollecting.setValue(progress);
	}
	
	public void setCoverageValue(int coverage){
		prgBarCoverage.setValue(coverage);
	}
	
	public void setSpecificityValue(int specificity){
		prgBarSpecificity.setValue(specificity);
	}
	
	public void setDensityValue(int density){
		prgBarDensity.setValue(density);
	}
	
	public Object getSelectedSSARange(){
		return cmbBoxSSARanges.getSelectedItem();
	}
	
	public void setSelectedSSARangeIndex(int index){
		cmbBoxSSARanges.setSelectedIndex(index);
	}
	
	public void setSSARangeModel(DefaultComboBoxModel model){
		cmbBoxSSARanges.setModel(model);
	}
	
	public int getSelectedSSARangeIndex(){
		return cmbBoxSSARanges.getSelectedIndex();
	}
	
	public int[] getMasterCollectionSelectedRows(){
		return tableMasterCollection.getSelectedRows();
	}
	
	public TableColumn getTableMasterCollectionColumn(int column){
		return tableMasterCollection.getColumnModel().getColumn(column);
	}
	
	public TableColumn getTableUncoveredTermsColumn(int column){
		return tableUncoveredTerms.getColumnModel().getColumn(column);
	}
	
	public TableColumn getTableQuickSumColumn(int column){
		return tableQuickSum.getColumnModel().getColumn(column);
	}
	
	public TableColumn getTableDetailSumColumn(int column){
		return tableDetailSum.getColumnModel().getColumn(column);
	}
	
}
